package com.xzy.es.demo.client;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * 创建、关闭ES客户端
 *
 * @author xzy
 * @date 2021/10/2016:23
 */
class ClientMain {

    public static void main(String[] args) throws IOException {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"))
        );

        // Do something ...

        // 关闭ES客户端
        esClient.close();
    }
}
